package com.zx.eval.service.impl;

import com.alibaba.druid.util.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zx.common.utils.PageUtils;
import com.zx.common.utils.Query;

import com.zx.eval.dao.EvalMatchDao;
import com.zx.eval.entity.EvalMatchEntity;
import com.zx.eval.service.EvalMatchService;


@Service("evalMatchService")
public class EvalMatchServiceImpl extends ServiceImpl<EvalMatchDao, EvalMatchEntity> implements EvalMatchService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String strTableId = (String)params.get("tableId");
        Integer tableId = 0;
        if(!StringUtils.isEmpty(strTableId)) {
            tableId = Integer.valueOf(strTableId);
        }

        String dimension = (String)params.get("dimension");
        IPage<EvalMatchEntity> page = this.page(
                new Query<EvalMatchEntity>().getPage(params),
                new QueryWrapper<EvalMatchEntity>()
                .eq(tableId >0, "table_id", tableId)
                .eq(!StringUtils.isEmpty(dimension), "code", dimension)
        );

        return new PageUtils(page);
    }

}